// formPackage/pages/coupon/exchangeCoupon/exchangeCoupon.js
import { chooseAndUploadQiniuActicon } from "../../../../service/upload_service"

let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    themeStyle: "",
    formData: {
      cardFront: "",
      cardBack: "",
      bankAccount: "",
      bankName: "",
      openBank: "",
      openName: "",
    },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },



  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (app.globalData.themeStyle) {
      this.setData({
        themeStyle: app.globalData.themeStyle
      })
    }
  },
  // 上传图片
  pushImgAction(e) {
    let type = e.detail.type;
    chooseAndUploadQiniuActicon('id').then(res => {
      console.log("JJLog:图片上传成功:" + JSON.stringify(res));
      wx.showToast({
        title: '上传成功',
      })
      if (type == "idFront") {
        this.setData({
          'formData.cardFront': res.complateUrl
        })
      } else if (type == "idBack") {
        this.setData({
          'formData.cardBack': res.complateUrl
        })
      }

    }).catch(err => {
      console.log("JJLog:图片上传失败:" + JSON.stringify(err));
      wx.showToast({
        title: '图片上传失败',
        icon: "none"
      })
    })
  },


})